package util

import (
	"bytes"
	"encoding/binary"
	"math/rand"
	"strconv"
	"time"
)

type Minio_config struct {
	Endpoint        string
	AccessKeyID     string
	SecretAccessKey string
	UseSSL          bool
	Bucket          string
	WithMasks       bool   // data chunks with masks
	MaskData        []byte // mask data of this org
}

func RandData(length int) []byte {
	var bytesBuffer bytes.Buffer
	time.Sleep(1 * time.Nanosecond)
	rand.Seed(time.Now().UnixNano())
	for i := 0; i < length/4; i++ {
		num := rand.Uint32()
		binary.Write(&bytesBuffer, binary.BigEndian, &num)
	}
	return bytesBuffer.Bytes()
}

func GetIP(orgID int) string {
	return SERVER_IPs[orgID] + ":909" + strconv.Itoa(orgID)
}

func GetURL(orgID int, bucket string, oid string) string {
	return "http://" + GetIP(orgID) + "/get?bucket=" + bucket + "&oid=" + oid
}
